package com.ems.controller;

import com.alibaba.fastjson.JSONObject;
import com.ems.exception.Result;
import com.ems.exception.ResultCode;
import com.ems.service.PublicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/public")
public class PublicController {

    @Autowired
    PublicService publicService;

    //sort

    @RequestMapping(value = "/personinfo",method = RequestMethod.GET)
    public Object personinfo(String username,Integer identity){
        return Result.ok().data(publicService.personInfo(username,identity));
    }

    @RequestMapping(value = "/test",method = RequestMethod.POST)
    public Object test(@RequestBody JSONObject jsonObject){
        if(jsonObject != null)
        {
            String test = jsonObject.getString("test");
            System.out.println(test);
            return Result.ok();
        }
        return Result.state(ResultCode.NULLPOINTER);

    }
}
